<template>
  <div class="element-pages">
    <!-- 分页 -->
    <h3>分页</h3>
    <div class="block">
      <span class="demonstration">显示总数</span>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="3"
        v-model:currentPage="currentPage1"
        :page-size="100"
        layout="total, prev, pager, next"
        :total="1000"
      ></el-pagination>
    </div>
    <div class="block">
      <span class="demonstration">调整每页显示条数</span>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="3"
        v-model:currentPage="currentPage2"
        :page-sizes="[100, 200, 300, 400]"
        :page-size="100"
        layout="sizes, prev, pager, next"
        :total="1000"
      ></el-pagination>
    </div>
    <div class="block">
      <span class="demonstration">直接前往</span>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="3"
        v-model:currentPage="currentPage3"
        :page-size="100"
        layout="prev, pager, next, jumper"
        :total="1000"
      ></el-pagination>
    </div>
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="pagesSizes"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalLength"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue'
export default {
  name: 'ElementPages',
  setup() {
    let currentPage = ref(3)
    let currentPage1 = ref(3)
    let currentPage2 = ref(3)
    let currentPage3 = ref(3)
    const pageSizes = [100, 200, 300, 400]
    let pageSize = ref(100)
    const totalLength = 400
    const handleSizeChange = (val) => {
      console.log(`每页 ${val} 条`)
    }
    const handleCurrentChange = (val) => {
      console.log(`当前页: ${val}`)
    }
    return {
      currentPage,
      currentPage1,
      currentPage2,
      currentPage3,
      pageSizes,
      pageSize,
      totalLength,
      handleSizeChange,
      handleCurrentChange
    }
  }
}
</script>
<style lang="scss">
.element-pages {
  margin: 20px;
  padding: 20px;
  background: #fff;
  border-radius: 10px;
  text-align: left;
  h2 {
    margin: 10px 0;
  }
}
</style>
